/*************************************************************************
> File Name: User.cpp 
> Author: Wu Junqiang
> Mail: 15769154659@163.com
> Created Time: 2018年01月23日 星期二 15时12分09秒
> Note: something about user
************************************************************************/

#include "User.h"

User::User()
{
	instance = DataMgr::instance();
}

User::~User()
{
}

Person SetUserInfo(string name,string password,string sex, string age, string height, string weight, string contactInfo, time_t datetime)
{
    Person person;

	person.name = name;
    person.passWord = password;
	person.sex = sex;
	person.age = age;
	person.height = height;
	person.weight = weight;
	person.contactInfo = contactInfo;
	person.datetime = datetime;

    return person;
}

bool User::AddUser(Person person)
{
	if(instance->Register(person.name,person.passWord))
	{
		cout << "AddUser successful !!" << endl;
		return true;
	}
	return false;
}

bool User::DelUser()
{
	return false;
}

bool User::ModifyUser()
{
	return false;
}

bool User::QueryUser(string name)
{
	if(instance->canRegister(name))
	{
		cout << "have this user " <<endl;
		return true;
	}
	return false;
}

bool User::UserLogin(string name,string passWord)
{
	if(instance->CheckPassword(name,passWord))
	{
		cout << "Login Successful !!!" << endl;
        return true;
    }
	return false;
}

bool User::UserLogout()
{
	return false;
}

bool User::InsertUserSportdata(SportData data)
{
     return  sport.SaveSportdata(data);

}

list<SportData> User::GetUserSportdata(string name)
{

    list<SportData> sportdata;
    sportdata = sport.querySportdata(name);
	return sportdata;
}

Person User::QueryUserInfo(string name)
{
    Person person;
    person = instance->QueryUsrData(name);
    return person;
}
